package com.ny.view;

import com.ny.entity.Stud;
import com.ny.service.StudentService;
import com.ny.service.impl.StudentServiceImpl;

import java.sql.SQLException;
import java.util.Scanner;



public class ReguserView {
    private StudentService uer1 = new StudentServiceImpl();

    public ReguserView() throws SQLException, ClassNotFoundException {
    }

    public void showRegisterForm() {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入用户名：");
        String username = scanner.next();

        System.out.println("请输入密码：");
        String pwd = scanner.next();

        System.out.println("请输入手机号：");
        String phone = scanner.next();

        Stud stud1 = new Stud();
        stud1.setStuName(username);
        stud1.setStuPwd(pwd);
        stud1.setStuPhone(phone);

        try {
            uer1.addStu(stud1);
            System.out.println("注册成功");
        } catch (Exception e) {
            System.out.println("注册失败: " + e.getMessage());
            e.printStackTrace();

        }
    }
}
